<template>
	<view class="container">
		<!-- 头部 -->
		<view class="header">
			<view class="hd_left">
				<text>热门话题</text>
			</view>
			<view class="hd_right" @click="toTalk">
				<text class="u-type-info">全部话题</text>
				<image src="https://app.zbzedu.com/static/WaChat/icon/forum/you@3x.png" mode=""
					style="width: 40rpx;height: 40rpx;"></image>
			</view>
		</view>
		<!-- 未登录状态 -->
		<view v-if="!isLoging">
			<view class="content" v-for="(item,index) in talkData" :key="index">
				<view class="con_title u-m-r-30" @click="toTalkList(item.tname)">
					<view class="img">
						<image src="https://app.zbzedu.com/static/WaChat/icon/forum/huati.png" mode="widthFix"
							style="width: 36rpx;"></image>
					</view>
					<text class="u-m-l-10 fon4-24 font-b u-line-1">{{item.tname}}</text>
				</view>
				<view class="con">
					<text class="font-20 u-type-info u-m-l-45">热度 {{item.tnum}}</text>
				</view>
			</view>
		</view>
		<!-- 登录状态 -->
		<view v-else>
			<view class="content" v-for="(item,index) in talkData" :key="index">
				<view class="con_item u-flex u-col-center" @click="toTalkList(item.tname)">
					<view class="item_left u-flex u-col-center" style="width: 600rpx;">
						<view class="img u-m-t-5">
							<image src="https://app.zbzedu.com/static/WaChat/icon/forum/huati.png" mode="widthFix"
								style="width: 36rpx;"></image>
						</view>
						<text class="u-m-l-10 font-b u-line-1"
							style="color: #2A6CAC;">{{item.tname}}</text>
					</view>
					<view class="item_right u-m-r-30 flex-1 u-text-right">
						<text class="font-20 u-type-info">热度 {{item.tnum}}</text>
					</view>
				</view>
			</view>
		</view>
		<u-gap height="20" bg-color="#EEEEEE"></u-gap>
	</view>
</template>

<script>
	import {
		request
	} from "../util/api";
	import {
		CHECK_TOKEN
	} from '../util/util.js'
	export default {
		data() {
			return {
				isLoging: CHECK_TOKEN(),
				talkData:[]
			}
		},
		created() {
			this.getData()
		},
		methods: {
			// 获取话题列表
			getData(){
				request({
					url:this.isLoging ? '/system/themeTopThree/3':'/system/wx/themeTopThree/3',
					method:"get"
				}).then(res=>{
					console.log(res)
					this.talkData=res.data
				})
			},
			toTalk() {
				uni.navigateTo({
					url: "/package/talk/talk"
				})
			},
			// 跳转到话题详细页面
			toTalkList(item){
				this.$u.route({
					url: '/package/forum/diaryList?type=' +encodeURIComponent(item)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		.header {
			display: flex;
			align-content: center;
			justify-content: space-between;
			margin: 20rpx 0;

			.hd_left {
				margin-left: 30rpx;
				font-size: 32rpx;
				font-weight: bold;
			}

			.hd_right {
				display: flex;
				align-items: center;
				margin-right: 10rpx;
			}
		}

		.content {
			margin-bottom: 20rpx;
			margin-left: 30rpx;

			.con_title {
				display: flex;

				text {
					color: #2A6CAC;
				}
			}
		}
	}
</style>
